// 人事架构
<template>
  <div>
   
       <TopManu  :thatF='this' @handcreate="handcreate"></TopManu>
   
  <el-row class="section-content">
    <el-col :span="6" class="organization-padd" style="borderRight:1px solid #02BF6B;">
      <el-col :span="24" style="marginTop:20px;">
            <el-tree
              style="marginTop:20px;"
              :data="data"
              :props="defaultProps"
              @node-click="handleClick"
              node-key="id"
               :default-expanded-keys="[2]"
              :expand-on-click-node="false">
              <div class="node" slot-scope="{ node }">
                <div >{{ node.label }}</div>
                <span class='custom-tree-title' style="text-align:left;"></span>
                <!-- <el-select style="opacity: 0;" v-model="treeValue" placeholder="请选择">
                  
                </el-select> -->
                
             <el-dropdown @command="handleCommand" >
  <span class="el-dropdown-link">
   操作菜单<i class="el-icon-arrow-down el-icon--right"></i>
  </span>
  <el-dropdown-menu slot="dropdown">
    <el-dropdown-item command="1">新增下级部门</el-dropdown-item>
    <el-dropdown-item command="2">编辑</el-dropdown-item>
    <el-dropdown-item command="3">删除</el-dropdown-item>
    
  </el-dropdown-menu>
</el-dropdown>
</div>
             
          </el-tree>
      </el-col>
    </el-col> 
    <el-dialog
      :title="diaLogTitle == 1?'增加部门':'编辑部门'"
      :visible.sync="dialogVisible"
      :fullscreen='true'
      :destroy-on-close="true"
      v-if="dialogVisible"
      :before-close="handleClose"
      >
      <el-form :inline="false" :model="formInline" label-width="auto" class="demo-form-inline">
        <el-col :span="24">
          <el-col :span="11">
            <el-form-item label="部门名字">
              <el-input v-model="formInline.name" placeholder="请输入部门"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12" :offset="1">
            <el-form-item label="领导人选择" >
                 <div class="yisheng">
                      <el-popover
                        placement="bottom-end"
                        v-model="visiblePatient"
                        trigger="focus"
                      >
                        <el-input
                          placeholder="姓名"
                          slot="reference"
                          v-model="formusername"
                          size="mini"
                          style="height:40px"
                        >
                     
                        </el-input>
                        <el-table
                          @row-click="xuanzePatient2"
                          height="300"
                          :data="
                            arr.filter(
                              data =>
                                !formusername ||
                                data.real_name
                                  .toLowerCase()
                                  .includes(formusername.toLowerCase())
                            )
                          "
                        >
                          <el-table-column
                            width="100"
                            property="number"
                            label="序号"
                          ></el-table-column>

                          <el-table-column
                            width="150"
                            property="real_name"
                            label="姓名"
                          ></el-table-column>
                          <el-table-column
                            width="100"
                            property="dept_name"
                            label="科室"
                          ></el-table-column>

                          <el-table-column
                            width="50"
                            property="gender"
                            label="性别"
                          >
                          <template slot-scope="scope">
       {{scope.row.gender==1?'男':scope.row.gender==2?'女':'未知'}}
      </template>
                          </el-table-column>

                      
                        </el-table>
                      </el-popover>
                       </div>
              
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="部门联系电话">
              <el-input v-model="formInline.link_tel" placeholder="请输入部门联系电话"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12" :offset="1">
            <el-form-item label="部门地址">
              <el-input v-model="formInline.address" placeholder="请输入部门地址"></el-input>   
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注">
              <el-input type="textarea" v-model="formInline.remark" placeholder="请输入备注"></el-input>
            </el-form-item>
          </el-col>
        </el-col>
        <el-col :span="24" style="font-size:24px;">
           补充信息
        </el-col>
        <el-col :span="24" style='marginTop:20px;'>
          <el-col :span="24">
             <el-col :span="11">
              <el-form-item label="科室代码" prop="description">
                  <el-input v-model="formInline.dept_info.code" placeholder="请输入科室代码"></el-input>
                <!-- <el-select style='width:100%;' class="op" v-model="formInline.dept_info.code" placeholder="请选择活动区域">
                  <el-option
                    v-for="item in officeOptions"
                    :key="item.value"
                    :label="item.name"
                    :value="item.value">
                  </el-option>
                </el-select> -->
              </el-form-item>
          </el-col>
          <el-col :span="12" :offset="1">
            <el-form-item label="成立日期" prop="build_time">
              <el-date-picker
                style="width:100%;"
                v-model="formInline.dept_info.build_time"
                type="date"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item> 
          </el-col>
          </el-col>
          <el-col :span="24">
            <el-col :span="11">
              <el-form-item label="床位数">
                <el-input v-model="formInline.dept_info.bed_num" placeholder="请输入床位数"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12" :offset="1">
              <el-form-item label="统筹区编号">
                <el-input v-model="formInline.dept_info.pool_area_no" placeholder="请输入统筹区编号"></el-input>
              </el-form-item>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-col :span="11">
              <el-form-item label="护士人数">
                <el-input v-model="formInline.dept_info.nurse_num" placeholder="请输入护士人数"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12" :offset="1">
              <el-form-item label="技师人数">
                <el-input v-model="formInline.dept_info.tech_num" placeholder="请输入技师人数"></el-input>
              </el-form-item>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-col :span="11">
              <el-form-item label="医师人数">
                <el-input v-model="formInline.dept_info.doctor_num" placeholder="请输入医师人数"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12" :offset="1">
              <el-form-item label="药师人数">
                <el-input v-model="formInline.dept_info.phar_num" placeholder="请输入药师人数"></el-input>
              </el-form-item>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-form-item label="描述" prop="number">
              <el-input type="textarea" v-model="formInline.dept_info.description" placeholder="请输入备注"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="服务范围" prop="number">
              <el-input type="textarea" v-model="formInline.dept_info.service_limit" placeholder="请输入备注"></el-input>
            </el-form-item>
          </el-col>
        </el-col>
      </el-form>
      <span slot="footer" class="dialog-footer" >
        <el-button  @click="dialogVisible = false,treeValue = ''">取 消</el-button>
        <el-button type="primary" style="background-color:#02BF6B;" @click="handelAdd">{{diaLogTitle == 1 ?'增 加':'编 辑'}}</el-button>
      </span>
    </el-dialog>
    <el-col :span="18"  class="pd-20">
       <el-col :span="24" style="margin:20px 0;text-align:right;">
          <el-col :span="18">
            <el-form :inline="false" :model="userInquire" label-width="50px" class="demo-form-inline">
              <el-col :span="7">
                <el-form-item label="编号">
                  <el-input v-model="userInquire.number" placeholder="编号"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="7">
                <el-form-item label="名字">
                  <el-input v-model="userInquire.real_name" placeholder="名字"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="状态">
                  <el-radio-group v-model="userInquire.status">
                    <el-radio label="">全部</el-radio>
                    <el-radio :label="1">启用</el-radio>
                    <el-radio :label="2">禁用</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col :span="2">
                <el-form-item>
                  <el-button type="primary" @click="()=>{tableData = [],getUserList()}">查询</el-button>
                </el-form-item>
              </el-col>
            </el-form>
          </el-col>
          <el-col :span="6">
             <el-button type="primary" @click="handleAddUserInfo">添加人员</el-button>
          </el-col>
       </el-col>
       <FromList  @handleEdit="handleEdit" @handleSwitchChange="handleSwitchChange" :tableData="tableData" :tableTitle="tableTitle" />
       <el-col :span="24" style="margin:20px 0;text-align:center;">
        <el-pagination
        background
        :current-page="userPage"
        :page-size="userLimit"
        layout="prev, pager, next"
        @current-change="handlePagination"
        :total="userCount">
        </el-pagination>
       </el-col>
    </el-col>
    <el-dialog
      title="提示"
      :visible.sync="handleDeleteFlag"
      width="30%">
      <span>您确定要删除么</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleDeleteFlag = false">取 消</el-button>
        <el-button type="primary" @click="remove">确 定</el-button>
      </span>
    </el-dialog>
    <div class="flex">
      <el-dialog
      :title="userButton == 1 ? '查看' : userButton == 2 ? '新增' : '编辑' "
      :visible.sync="userFlag"
      width="100%"
      top="0vh"
      :destroy-on-close="true"
      v-if="userFlag"
      :before-close="handleCloseUser"
      :fullscreen='true'
      >
      <span class="scrool" style="padding:0 10px;">
        <el-col :span="24">
          <el-form :inline="false" :model="user" class="demo-form-inline">
              <el-col :span="24" style="margin:0 0 10px 0;font-size:26px;">基本信息</el-col>
              <!-- 上面字段 -->
              <el-col :span="24" class="flexBetween">
                <el-col :span="5">
                  <el-form-item label="账户名">
                    <el-input v-model="user.name" :disabled="userButton == 1" placeholder="请输入账户名"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="5">
                  <el-form-item label="用户姓名" >
                    <el-input v-model="user.real_name"  :disabled="userButton == 1" placeholder="请输入用户姓名"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="5">
                  <el-form-item label="手机号">
                    <el-input v-model="user.phone" :disabled="userButton == 1" placeholder="请输入手机号"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="5">
                  <el-form-item label="人员类别" >
                    <el-select style='width:100%;' :disabled="userButton == 1"  v-model="user.user_type"  filterable placeholder="请选择人员类别">
                        <el-option
                          v-for="item in userType"
                          :key="item.id"
                          :label="item.name"
                          :value-key="item.id"
                          :value="item.id">
                        </el-option>
                      </el-select>
                  </el-form-item>
                </el-col>
              </el-col>
              <el-col :span="24" class="flexBetween">
                <el-col :span="5">
                  <el-form-item label="角色">
                    <el-select style="width:100%;" :disabled="userButton == 1" v-model="user.role_id" placeholder="请选择角色">
                        <el-option
                          v-for="item in roleUser"
                          :key="item.id"
                          :label="item.name"
                          :value-key="item.id"
                          :value="item.id">
                        </el-option>
                      </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="5">
                  <el-form-item label="科室" >
                     <el-cascader
                     ref="cascader"
                        v-model="user.department_id_arr"
                        :options="optionsOne"
                        :props="props2One"
                        @change="handleChange"
                        clearable></el-cascader>
                    <!-- <el-select style="width:100%;" :disabled="userButton == 1" v-model="user.dept_id" placeholder="请选择科室">
                        <el-option
                          v-for="item in departmentArr"
                          :key="item.id"
                          :label="item.name"
                          :value-key="item.id"
                          :value="item.id">
                        </el-option>
                      </el-select> -->
                      <!-- <selectInput :thatF="this"></selectInput> -->
                    <!-- <el-input v-model="user.department_name"  placeholder="请输入科室"></el-input> -->
                  </el-form-item>
                </el-col>
                <el-col :span="5">
                </el-col>
                <el-col :span="5">
                </el-col>
              </el-col>
              <!-- 个人信息 -->
              <el-col :span="24" style="font-size:24px;marginTop:20px;">
                个人信息
              </el-col>
              <!-- 下面字段 -->
              <el-col :span="24" style='marginTop:20px;' >
                <el-col :span="24" class="flexBetween">
                  <el-col :span="5">
                  <el-form-item label="身份证号">
                    <el-input v-model="user.id_card"
                    @blur="getInfo2(user.id_card)"
                     :disabled="userButton == 1" placeholder="请输入身份证号"></el-input>
                  </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="生日" prop="build_time">
                      <el-date-picker
                        :disabled="userButton == 1"
                        style="width:100%;"
                          v-model="user.birthday"
                          type="date"
                          placeholder="选择生日">
                        </el-date-picker>
                    </el-form-item> 
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="性别">
                      <el-select style="width:100%;" v-model="user.gender" :disabled="userButton == 1" placeholder="请选择性别">
                        <el-option
                          v-for="item in sex"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="婚姻状况">
                      <el-select style="width:100%;" :disabled="userButton == 1" v-model="user.marriage" placeholder="请选择婚姻状况">
                        <el-option
                          v-for="item in marriage"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-col>
                <el-col :span="24" class="flexBetween">
                  <el-col :span="5">
                   <el-form-item label="职称">
                      <el-select style="width:100%;" :disabled="userButton == 1" v-model="user.positional_id" placeholder="请选择职称">
                        <el-option
                          v-for="item in positionalOptions"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="职务">
                      <el-select style="width:100%;" :disabled="userButton == 1" v-model="user.post_id" placeholder="请选择职务">
                        <el-option
                          v-for="item in postOptions"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"> 
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    
                  </el-col>
                  <el-col :span="5">
                   
                  </el-col>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="个人介绍">
                      <el-input type="textarea" :disabled="userButton == 1" v-model="user.description" placeholder="请输入个人介绍"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24" class="flexBetween">
                  <el-col :span="5">
                    <el-form-item label="医师执业证">
                      <el-input v-model="user.physician_number" :disabled="userButton == 1"  placeholder="请输入医师执业证"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="医师资格证">
                      <el-input v-model="user.physician_qualification_number" :disabled="userButton == 1" placeholder="请输入医师资格证"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="护士执业证">
                      <el-input v-model="user.nurse_number" :disabled="userButton == 1" placeholder="请输入护士执业证"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="护士资格证">
                      <el-input v-model="user.doctor_register_number" :disabled="userButton == 1" placeholder="请输入护士资格证"></el-input>
                    </el-form-item>
                  </el-col>
                </el-col>
                <el-col :span="24" class="flexBetween">
                  <el-col :span="5">
                    <el-form-item label="入职时间">
                      <el-date-picker
                        :disabled="userButton == 1"
                        style="width:100%;"
                        v-model="user.join_time"
                        type="date"
                        placeholder="">
                      </el-date-picker>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="医保编号">
                      <el-input v-model="user.medical_insurance_number" :disabled="userButton == 1" placeholder="请输入医保编号"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="是否医保医师">
                        <el-select style="width:100%;" :disabled="userButton == 1" v-model="user.is_medical_insurance_doctor" placeholder="请选择是否医保医生">
                          <el-option
                            v-for="item in is_medicalOptions"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </el-option>
                        </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                      <el-form-item label="药师资格证">
                        <el-input v-model="user.drug_number" :disabled="userButton == 1" placeholder="请输入药师资格证"></el-input>
                      </el-form-item>
                  </el-col>
                </el-col>
                <el-col :span="24">
                  <el-form-item label="备注" prop="number">
                    <el-input type="textarea" v-model="user.remark" :disabled="userButton == 1" placeholder="请输入备注"></el-input>
                  </el-form-item>
                </el-col>
              </el-col>
              <!-- 用户权限 -->
              <el-col :span="24" style="font-size:24px;">用户权限</el-col>
              <el-col :span="24" >
                <el-col :span="24" class="flexBetween">
                  <el-col :span="5">
                    <el-form-item label="职业级别">
                      <el-select style="width:100%;" :disabled="userButton == 1" v-model="user.practice_level" placeholder="请选择职业等级">
                        <el-option
                          v-for="item in practice_levelOptions"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="处方等级">
                      <el-select style="width:100%;" :disabled="userButton == 1" v-model="prescription" placeholder="请选择处方等级">
                        <el-option
                          v-for="item in prescriptionOptions"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="抗菌药物等级">
                      <el-select style="width:100%;" :disabled="userButton == 1" v-model="antibiosis" placeholder="请选择抗菌药物等级">
                        <el-option
                          v-for="item in antibiosisOptions"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="精神药物等级">
                      <el-select style="width:100%;" :disabled="userButton == 1" v-model="spirit" placeholder="请选择精神药物等级">
                        <el-option
                          v-for="item in spiritOptions"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-col>
                <el-col :span="24" class="flexBetween">
                  <el-col :span="5">
                    <el-form-item label="毒麻药物等级">
                      <el-select style="width:100%;" :disabled="userButton == 1" v-model="narcotic" placeholder="请选择毒麻药物等级">
                        <el-option
                          v-for="item in narcoticOptions"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="贵重药物等级">
                      <el-select style="width:100%;" :disabled="userButton == 1" v-model="precious" placeholder="请选择贵重药物等级">
                        <el-option
                          v-for="item in preciousOptions"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="病人查看权限">
                      <el-select style="width:100%;" :disabled="userButton == 1" v-model="user.look_patient" placeholder="请选择病人查看权限">
                        <el-option
                          v-for="item in look_patientOptions"
                          :key="item.value"
                          :label="item.name"
                          :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="病历权限">
                      <el-select style="width:100%;" :disabled="userButton == 1" v-model="user.look_case" placeholder="请选择病例权限">
                        <el-option
                          v-for="item in look_patientOptions"
                          :key="item.value"
                          :label="item.name"
                          :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-col>
                <el-col :span="24" class="flexBetween">
                  <el-col :span="5">
                    <el-form-item label="直属上级" >
                       <div class="yisheng">
                      <el-popover
                        placement="bottom-end"
                        v-model="visiblePatient"
                        trigger="focus"
                      >
                        <el-input
                          placeholder="姓名"
                          slot="reference"
                          v-model="formusername"
                          size="mini"
                          style="height:40px"
                        >
                     
                        </el-input>
                        <el-table
                          @row-click="xuanzePatient"
                          height="300"
                          :data="
                            arr.filter(
                              data =>
                                !formusername ||
                                data.real_name
                                  .toLowerCase()
                                  .includes(formusername.toLowerCase())
                            )
                          "
                        >
                          <el-table-column
                            width="100"
                            property="number"
                            label="序号"
                          ></el-table-column>

                          <el-table-column
                            width="150"
                            property="real_name"
                            label="姓名"
                          ></el-table-column>
                          <el-table-column
                            width="100"
                            property="dept_name"
                            label="科室"
                          ></el-table-column>

                          <el-table-column
                            width="50"
                            property="gender"
                            label="性别"
                          >
                          <template slot-scope="scope">
       {{scope.row.gender==1?'男':scope.row.gender==2?'女':'未知'}}
      </template>
                          </el-table-column>

                      
                        </el-table>
                      </el-popover>
                       </div>
                      </el-form-item>
                  </el-col>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="科室权限">
                      <el-cascader
                        v-model="user.dep_ids"
                        :options="optionsOne"
                        :props="propsOne"
                        clearable></el-cascader>
                    </el-form-item>
                </el-col>
              </el-col>
          </el-form>
        </el-col>
      </span>
      <span slot="footer" class="dialog-footer">
        <el-button  @click="userFlag = false">取 消</el-button>
        <el-button type="primary" style="background-color:#02BF6B;" v-if="userButton != 1"  @click="handelAddUser">{{userButton == 2 ? '新增' : userButton == 3 ? '编辑' : ''}}</el-button>
      </span>
      </el-dialog>
    </div>  
   
  </el-row>


  <el-dialog
  :title="yibao.title"
  :destroy-on-close	="true"
  :show-close="false"
  :visible.sync="yibao.dialogShow"
  :close-on-click-modal="false"
  v-if="yibao.dialogShow"
  width="30%"
  top="0"
  >
  <span>
       <el-cascader
        :options="optionsOne"
          v-model="yibao.id"
         :props="propsOne"
      
        clearable></el-cascader>
  </span>
    <span slot="footer" class="dialog-footer">
    <el-button @click="yibao.dialogShow = false;yibao.id=''">取 消</el-button>
    <el-button type="primary" @click="editYiBao()">确 定</el-button>
  </span>

</el-dialog>
  </div>
</template>

<script>
let that
import FromList from "@/forComponents/fromList/fromList"
import {getOrganization,addOrganization,removeOrganization,modificationOrganization,getDetails,handleDictIndex,deptIndex} from "@/api/organization"
import TopManu from "@/components/TopMenu"
import {getUserList,handleAddUser,getRoleIndex,getUserProfile,handleDelete,handleSetStatus,resetPassword} from "@/api/user"
import {objectValueAllEmpty} from "@/utils/ifObject"
import selectInput from "@/components/select"
  export default {
    name:"organization",
  data(){
    return {
      yibao:{
         dialogShow:false,
         title:'',
         key:'',
         id:'',
      },
     
    
      index:0, //loding控制
      loading:"",
      keyValue:"",
      topmanuArry:[{
        class:'icon-his_55_ruku',
        name:'科室上传',
        key:'update',
      },{
        class:'icon-his_58_tuihui',
        name:'科室编辑',
        key:'edit',
      },{
        class:'icon-his_56_chuku',
        name:'科室撤销',
        key:'revoke',
      }],
      tableData:[
        
      ],
      tableTitle:[
        {
          prop:"number",
          name:"编号",
          type:1,
          width:80
        },
        {
          prop:"medical_insurance_number",
          name:"医保编码",
          type:1,
          width:150
        },
        {
          prop:"name",
          name:"账户名",
          type:1,
        },
        {
          prop:"real_name",
          name:"姓名",
          type:1,
          
        },
        {
          prop:"dept_name",
          name:"科室",
          type:1,
          width:100
        },
         {
          prop:"user_type",
          name:"人员类别",
          type:1,
        },
        {
          prop:"phone",
          name:"联系方式",
          type:1,
           width:110
        },
        {
          prop:"status",
          name:"状态",
          type:5,
          
        },
        {
          prop:"",
          name:"操作",
          type:4,
          width:300,
          fixed:"right",
          arr:[
            {
              type:"success",
              number:1,
              name:"查看"
            },
            {
              type:"info",
              number:2,
              name:"编辑"
            },
            {
              type:"danger",
              number:4,
              name:"删除"
            },
            {
              type:"",
              number:5,
              name:"重置密码"
            }
          ]
        },
      ],
      
      treeNodeId:"",
      defaultProps: {
        children: 'children',
        label: 'name',
        isLeaf:"isLeaf"
      },
      dialogVisible:false, //控制添加组织开关
      data:[],
      arr:[], //组织信息
      page:0,
      limit:5,
      formInline: {
        name: '', //组织名字
        link_tel:"", //电话好
        head_user:"", //领导人
        address:"", //地址
        remark:"",
        dept_info:{
          code:"",
          description:"",
          service_limit:"",
          build_time:"",
          bed_num:"",
          pool_area_no:"",
          doctor_num:"",
          phar_num:"",
          nurse_num:"",
          tech_num:""
        },
        
      },
      saveFlag:false, //控制完善编辑
      handleDeleteFlag:false,
      handlePerfectFlag:false,
      highlightCurrentRow:true,
      officeOptions:[

      ],
      options:[
        {
          label:"新增下级部门",
          value:"1"
        },
        {
          label:"编辑",
          value:"2"
        },
        {
          label:"删除",
          value:"3"
        }
      ],
      sex:[
       {
         value:1,
         label:"男"
       },
       {
         value:2,
         label:"女"
       },
       {
         value:3,
         label:"未知"
       }
      ],
      marriage:[ //婚姻状况
        {
          value:1,
          label:"未婚"
        },
        {
          value:2,
          label:"已婚"
        },
        {
          value:3,
          label:"离异"
        },
        {
          value:4,
          label:"丧偶"
        },
      ], 
      nodeCurr:{},
      treeValue:"",
      diaLogTitle:1,
      userFlag:false,
      user:{
        name:"", //账户名
        real_name:"", //姓名
        phone:"", //手机号
        department_id:"",//部门编号
        department_name:"", //部门名字
        user_type:"", //人员类别
        role_id:"",  //角色Id
        role_name:"", //角色名字
        dept_name:"",
        id_card:"", //身份证号
        gender:"", //性别
        birthday:"",  //生日
        marriage:"", //婚姻状态
        description:"", //个人介绍
        join_time:"", //入职时间
        physician_number:"", //医师执业证编码
        drug_number:"", //药师资格证
        physician_qualification_number:"", //医师资格证编码
        nurse_number:"", //护士执业证书编码
        doctor_register_number:"", //医生注册编号
        medical_insurance_number:"", //医保编码
        is_medical_insurance_doctor:"", //是否医保医师
        remark:"", //备注信息
        practice_level:"", //职业级别
        prescription:"", //处方等级
        antibiosis:"", //抗菌药物等级
        spirit:"", //精神药物等级
        narcotic:"", //毒麻药物等级
        precious:"", //贵重药物等级
        look_patient:"", //病人查看权限
        dep_ids:"", //科室权限
        look_case:"", //病例权限
        leader:"", //直属上级
        dep_extra:"", //科室权限显示
        post_id:"",  //职务id
        positional_id:"", //职称Id
        dept_id:"",
        department_id_arr:[]
      },
      look_patientOptions:[
        {
          name:"个人",
          value:1
        },
        {
          name:"科室",
          value:2
        },
        {
          name:"全院",
          value:3
        }
      ],
      userType:[],   //人员类别选择框内容
      is_medicalOptions:[   //是否医保医生选择框
        {
          label:"是",
          value:1
        },
        {
          label:"否",
          value:2
        }
      ],
      practice_levelOptions:[], //职业等级选择框
      prescriptionOptions:[], //处方等级
      antibiosisOptions:[], //抗菌药物等级
      spiritOptions:[], //精神药物等级
      narcoticOptions:[], //毒麻药物等级
      preciousOptions:[], //贵重药物等级
      userButton:1,  //1查看 2新增 3编辑
      roleUser:[
        
      ],
      departmentArr:[

      ],
      userInfo:{

      },
      userInquire:{
        status:"",
        real_name:"",
        number:""
      },
      userPage:1,
      userLimit:10,
      userCount:1000,
      optionsOne:[], //科室权限
      propsOne: {
       
        children: 'children',
        label: 'name',
        value:"id",
        checkStrictly:true
      },
      props2One: {
       
        children: 'children',
        label: 'name',
        value:"id",
       
      },
      postOptions:[], //职务
      positionalOptions:[],//职称
      formusername:'',
      visiblePatient:false,
    }
  },
  computed:{
    prescription:{
      get(){
        if(this.user.prescription==0 || this.user.prescription==''){
          return this.user.prescription='';
        }else{
          return this.user.prescription;
        }
      },
      set(val){
          this.user.prescription = val
      }
    },
    antibiosis:{
       get(){
        if(this.user.antibiosis==0 || this.user.antibiosis==''){
          return this.user.antibiosis='';
        }else{
          return this.user.antibiosis;
        }
      },
      set(val){
          this.user.antibiosis = val
      }
    },
    spirit:{
      get(){
        if(this.user.spirit==0 || this.user.spirit==''){
          return this.user.spirit='';
        }else{
          return this.user.spirit;
        }
      },
      set(val){
          this.user.spirit = val
      }
    },
    narcotic:{
      get(){
        if(this.user.narcotic==0 || this.user.narcotic==''){
          return this.user.narcotic='';
        }else{
          return this.user.narcotic;
        }
      },
      set(val){
          this.user.narcotic = val
      }
    },
    precious:{
      get(){
        if(this.user.precious==0 || this.user.precious==''){
          return this.user.precious='';
        }else{
          return this.user.precious;
        }
      },
      set(val){
          this.user.precious = val
      }
    },
    leader:{
       get(){
        if(this.user.leader==0 || this.user.leader==''){
          return this.user.leader='';
        }else{
          return this.user.leader;
        }
      },
      set(val){
          this.user.leader = val
      }
    }
  },
  mounted(){
    that = this 
    that.getList()
    that.handleDictIndex()
    that.getRoleIndex()
    that.deptIndex()
    that.searchHeadUser('')
  },
  components:{
     FromList,
     TopManu,
      selectInput,
  },
  watch:{
    treeValue(to,key){
      if(to == 1) that.dialogVisible = true,that.diaLogTitle = 1
      if(to == 2) that.dialogVisible = true,that.diaLogTitle = 2,that.getDetails()
      if(to == 3) that.handleDeleteFlag = true 
    }
  },
  methods:{
     xuanzePatient(item) {
      console.log("item", item);
    this.formusername=item.real_name
    this.user.leader=item.id
    this.visiblePatient = false;

    },
        xuanzePatient2(item) {
      console.log("item", item);
    this.formusername=item.real_name
    this.formInline.head_user=item.id
    this.visiblePatient = false;

    },
    editYiBao(){
      console.log(this.yibao.id)
      if(this.yibao.id.length<=0){
        return this.$message.error('请选择科室')
      }
      let d={
        id:this.yibao.id[this.yibao.id.length-1],
      }
      let url='';
    
               if(this.yibao.key=='update'){
                  d.type=1;
                   url='getdeptUploadYb'
               }else if(this.yibao.key=='edit'){
                  d.type=2;
                   url='getdeptUploadYb'
               }else if(this.yibao.key=='revoke'){ 
                  url='getdeptBackYb'
               }
 
 
              
                 this['_API'][url](d).then(res=>{
         
                 if(res.code==200){

                      this.yibao.dialogShow=false;
                      this.yibao.id='';
                 }
      })
    },
    handcreate(item){
      console.log(item)
       this.yibao.title=item.name;
       this.yibao.key=item.key;
       this.yibao.dialogShow=true;
      
    },
    // 获取组织机构
    deptIndex(){
      deptIndex()
      .then(res=>{
        that.optionsOne = res.data;
        that.optionsOne = that.deleteChildren(that.optionsOne)
         that.departmentArr = that.optionsOne[0].children;
        console.log(" that.optionsOne", that.optionsOne)
        console.log(" that.departmentArr", that.departmentArr)
      })
      .catch(e=>{
        this.$message({
          message:e.message,
          type: 'error'
        });
      })
    },
    deleteChildren(arr) {
      let childs = arr;
      for (let i = childs.length; i--; i > 0) {
        if (childs[i].children) {
          if (childs[i].children.length) {
            this.deleteChildren(childs[i].children);
          } else {
            delete childs[i].children;
          }
        }
      }
      return arr;
    },
    handleChange(value){
      console.log('ccccc',value)
      let nodesInfo = this.$refs['cascader'].getCheckedNodes()
			console.log('nodesInfo>>>>>',nodesInfo)
      let path_name = nodesInfo[0]['pathLabels']
      that.user.department_id = Object.values(value).join(',')
      that.user.department_name = Object.values(path_name).join('/')
        console.log('path_name',that.department_name)
    },
    handleAddUserInfo(){ 
     this.userFlag = true
     Object.keys(this.user).forEach(key=>{
       this.$set(this.user,key,"")
     })
     
     this.$set(this.user,'department_id',this.nodeCurr['id'])
     this.$set(this.user,'department_name',this.nodeCurr['name'])
     console.log(this.user)
     this.getDataIndex()
     this.userButton = 2
    },
    handlePagination(e){
      that.userPage = e
      that.tableData = []
      that.getUserList()
    },
    // switch变化
    handleSwitchChange(data){
      let {data:list} = data
      that.handleSetStatus(list.id,list.flag ? 1 : 2)
    },
    //获取人员类别
    getDataIndex(){
      handleDictIndex({group_id:"1,2,38,41,42,43,44,45,46"})
      .then(res=>{
        console.log(res.data)
        if(res.data.length != 0){
          that.userType = res.data[0].items
          that.positionalOptions = res.data[1].items
          that.postOptions = res.data[2].items
          that.spiritOptions = res.data[3].items
          that.prescriptionOptions = res.data[4].items
          that.antibiosisOptions = res.data[5].items
          that.narcoticOptions = res.data[6].items
          that.preciousOptions = res.data[7].items
          that.practice_levelOptions = res.data[8].items

        }
      })
      .catch(e=>{
        this.$message({
          message:e.message,
          type: 'error'
        });
      })
    },
    //获取角色
    getRoleIndex(){
      getRoleIndex()
      .then(res=>{
        that.roleUser = res.data.list
      })
      .catch(e=>{
        this.$message({
          message:e.message,
          type: 'error'
        });
      })
    },
    //添加人员
    handelAddUser(){
     
      let data = {
        name:"",
        real_name:"",
        phone:"",
        user_type:"",
        role_id:"",
        department_id:"",
      
       
      }
      Object.keys(data).forEach(key=>{
        data[key] = that.user[key]
      })
      console.log(data)
      if(!objectValueAllEmpty(data)){
        this.$message({
            message:"请至少填写基本信息",
            type: 'error'
          });
        return false
      }
     
      that.roleUser.forEach(item=>{
        if(item.id == data.role_id) that.user.role_name = item.name 
      })
      //  that.departmentArr.forEach(item=>{
      //   if(item.id == data.dept_id) {
      //     that.user.dept_name = item.name 
      //     that.user.department_id = item.parent_id
      //   }
      // })
      data = {}
      Object.keys(that.user).forEach(key=>{
        if(that.userButton != 3){
          if(key != "id"){
            data[key] = that.user[key]      
          }
        }else{
            data[key] = that.user[key]
        }
      })
    
      let arr= []
      if(data.dep_extra){
        data.dep_extra = JSON.stringify(data.dep_ids)
        data.dep_extra.forEach(item=>{
        item.forEach(key=>{
            arr.push(key)
          })
        })
        data.dep_extra = Array.from(new Set(arr)).join(",")
      }
      console.log(data)
      handleAddUser({...data})
      .then(res=>{
        if(res.code == 200){
          that.index--
          that.userFlag = false
          that.tableData = []

          Object.keys(that.user).forEach(key=>{
            that.user[key] = ""
          })
          that.getUserList()
          
          this.$message({
            message:that.userButton == 2 ? '添加成功' : '编辑成功',
            type: 'success'
          });
        }
      })
      .catch(e=>{
        this.$message({
          message:e.message,
          type: 'error'
        });
      })
    },
    // 获取账户列表
    getUserList(){
      that.index++
      getUserList({dept_id:that.nodeCurr.id,page:that.userPage,limit:that.userLimit,...that.userInquire})
      .then(res=>{
        that.index--
        res.data.list.forEach(item=>{
          item.status == 1 ? item.flag = true : item.flag = false
        })
        that.tableData = that.tableData.concat(res.data.list)
        that.userCount = res.data.count
        console.log(that.userCount)
        console.log(that.tableData)
        
      })
      .catch(e=>{
        that.index--
        this.$message({
          message:e.message,
          type: 'error'
        });
      })
    },   
    //增加部门
    handelAdd(){
      if(that.treeValue == 1) that.append()
      if(that.treeValue == 2) that.handleSave()
    },
    // 左边组织机构点击
    handleClick(e){
      this.page = 0
      that.tableData = []
      that.nodeCurr = e
      that.getUserList()
    },
    //修改账户状态
    handleSetStatus(e,q){
      that.index++
      handleSetStatus({id:e,status:q})
      .then(res=>{
        that.index--
        this.$message({
          message:"修改状态成功",
          type: 'success'
        });
        that.tableData = []
        that.getUserList()
      })
      .catch(e=>{
        that.index--
        this.$message({
          message:e.message,
          type: 'error'
        });
      })
    },
    //删除账户
    handleDelete(){
      that.index++
      handleDelete({id:that.userInfo.id})
      .then(res=>{
        that.index--
        this.$message({
          message:"删除成功",
          type: 'success'
        });
        that.tableData = []
        that.getUserList()
      })
      .catch(e=>{
        that.index--
        this.$message({
          message:e.message,
          type: 'error'
        });
      })
    },
    // 获取科室的类型
    handleDictIndex(){
      that.index++
      handleDictIndex({group_id:3})
      .then(res=>{
        that.index--
        that.officeOptions = res.data
      })
      .catch(e=>{
        that.index--
        this.$message({
          message:e.message,
          type: 'error'
        });
      })
    },
    handleEdit(e){
      console.log(e.key,e.data)
      switch(e.key){
        case 1:
          that.userInfo = e.data
          that.getUserProfile()
          that.getDataIndex()
          that.getRoleIndex()
          that.userFlag = true
          that.userButton = 1
        break
        case 2:
          that.userInfo = e.data
          that.getUserProfile()
          that.getDataIndex()
          that.getRoleIndex()
          that.userFlag = true
          that.userButton = 3
        break
        case 3:
          that.handleSetStatus(e.data.id,e.data.status == 1?2:1)
        break
        case 4:
          that.userInfo = e.data
          that.handleDelete()
        break
         case 5:
         this.$confirm('是否重置密码?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
            resetPassword({ uid: e.data.id })
                .then(res => {
                 if (res.code==200) {
                    this.$message({
            type: 'success',
            message: res.message
          });
                 }
                })
                .catch(e => {});
         
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          });          
        });
        break
      }
    },
    // 清除表单信息
    deleteFrom(){
      Object.keys(that.formInline).forEach(key=>{
        if(key != "dept_info"){
          that.formInline[key] = ''
        }
      })
      Object.keys(that.formInline.dept_info).forEach(key=>{
        that.formInline.dept_info[key] = ""
        that.$set(that.formInline.dept_info,key,"")
      })
    },
    //获取账户全部信息
    getUserProfile(){
      that.index++
      getUserProfile({uid:that.userInfo.id})
      .then(res=>{
        console.log(res)
        Object.keys(that.user).forEach(key=>{
          that.$set(that.user,key,res.data[key])
        })
        that.user.role_id = Number(that.user.role_id)
         that.user.dept_id = Number(that.user.dept_id)
         that.user.leader=res.data.leader
        console.log(res.data.get_positional_title)
       that.arr.forEach(res2=>{
          
                  if(res2.id==that.user.leader){
                
                     that.formusername= res2.real_name
                  }
        }) 
        that.user.department_id_arr = res.data.department_id.split(',').map(item=>{
          return Number(item)
        })
       

        if(res.data.get_positional_title){
        
          that.user.positional_id = res.data.get_positional_title.id
        }
        if(res.data.get_post){
          that.user.post_id = res.data.get_post.id
        }
        that.user.is_medical_insurance_doctor = Number(that.user.is_medical_insurance_doctor)
        that.user.id = res.data.id
        that.join_time=res.data.join_time?'':res.data.join_time 
        that.birthday=res.data.birthday?'':res.data.birthday
        console.log(that.user)
      })
      .catch(e=>{
        console.log("进入")
        this.$message({
          message:e.message,
          type: 'error'
        });
      })
    },
    // 编辑部门
    handleSave(){
      that.index++
  
      modificationOrganization({id:that.nodeCurr.id,...that.formInline})
      .then(res=>{
        
      that.treeValue = ""
        console.log("res",res)
        that.deleteFrom()
        that.dialogVisible = false
        that.getList()
        this.$message({
          message:"编辑成功",
          type: 'success'
        });
        
        that.index--
      })
      .catch(e=>{
        that.index--
        // console.log(e)
        // this.$message({
        //   message:e.message,
        //   type: 'error'
        // });
      })
    },  
    //获取部门信息
    getDetails(){
      that.index++
      getDetails({id:that.nodeCurr.id})
      .then(res=>{
        if(res.data.get_head_user!==null){
             that.formusername = res.data.get_head_user.real_name
        }
      
        let {data,} = res
        that.searchHeadUser()
        that.handleDictIndex()
        Object.keys(that.formInline).forEach(key=>{
          console.log(key)
          if(key != "dept_info"){
            that.$set(that.formInline,key,data[key])
          }
        })
        let arr = {
          description:"",
          service_limit:"",
          build_time:"",
          bed_num:"",
          pool_area_no:"",
          doctor_num:"",
          phar_num:"",
          nurse_num:"",
          tech_num:"",
          code:""
        }
        Object.keys(arr).forEach(key=>{
          arr[key] = data[key]
        })
        that.formInline.dept_info = arr
        console.log(that.formInline)    
        that.index--
      })
      .catch(e=>{
        that.index--
        this.$message({
          message:e.message,
          type: 'error'
        });
      })
    },
       getInfo2(idCard) {
        let sex = null;
        let birth = null;
        let myDate = new Date();
        let month = myDate.getMonth() + 1;
        let day = myDate.getDate();
        let age = 0;

        if (idCard.length === 18) {
          age = myDate.getFullYear() - idCard.substring(6, 10) - 1;
          sex = idCard.substring(16, 17);
          birth = idCard.substring(6, 10) + "-" + idCard.substring(10, 12) + "-" + idCard.substring(12, 14);
          if (idCard.substring(10, 12) < month || idCard.substring(10, 12) === month && idCard.substring(12, 14) <= day)
            age++;

        }
        if (idCard.length === 15) {
          age = myDate.getFullYear() - idCard.substring(6, 8) - 1901;
          sex = idCard.substring(13, 14);
          birth = "19" + idCard.substring(6, 8) + "-" + idCard.substring(8, 10) + "-" + idCard.substring(10, 12);
          if (idCard.substring(8, 10) < month || idCard.substring(8, 10) === month && idCard.substring(10, 12) <= day)
            age++;
        }

        if (sex % 2 === 0)
          sex = 0; // 性别代码 1代表男，0代表女，暂时不涉及其他类型性别
        else
          sex = 1;
           this.user.gender=sex
         this.user.birthday=birth
       
        // return {
        //   age,
        //   sex,
        //   birth
        // }
      },
    //搜索领导人信息
    searchHeadUser(e){
      that.index++
      console.log(e+'')
      getUserList({name:this.formusername,page:that.page,limit:3000})
      .then(res=>{
        console.log(res)
        if(res.data.list.length != 0){
          that.arr = res.data.list
        }
        that.index--
      })
      .catch(e=>{
        that.index--
         this.$message({
          message:e.message,
          type: 'error'
        });
      })
    },
    //获取左边组织机构
    getList(){
      that.index++
      getOrganization()
      .then(res=>{
        res.data.map(item=>{
          return item.label = item.name
        })
        that.nodeCurr = res.data[0]
        console.log(that.nodeCurr)
        that.getUserList()
        that.data = res.data
        that.index--
      })
      .catch(e=>{
        that.index--
        this.$message({
          message:e,
          type: 'error'
        });
      })
    },
    handleNodeClick(e){
      this.treeNodeId = e.$treeNodeId
    },
     handleCommand(val){
    console.log(val)
      this.treeValue=val
  },
    //增加部门编辑部门取消
    handleClose(){
      that.treeValue = ""
      that.dialogVisible = false
      Object.keys(that.formInline.dept_info).forEach(key=>{
        that.formInline.dept_info[key] = ""
      })
      handleCommand
    },
    // 右边取消
    handleCloseUser(){
      that.userFlag = false
      Object.keys(that.user).forEach(key=>{
        that.$set(that.user,key,"")
      })
      
    },
    // 增加部门
    append() {
      // if(!objectValueAllEmpty(that.formInline)){
      //   this.$message({
      //       message:"请认真填写表单信息",
      //       type: 'error'
      //     });
      //   return false
      // }
      that.index++
       addOrganization({parent_id:that.nodeCurr.id,...that.formInline})
        .then(res=>{
          that.index--
          that.dialogVisible = false
          that.treeValue = ""
          that.getList()
          Object.keys(that.formInline).forEach(key=>{
            if(key != "dept_info"){
              that.formInline[key] = ''
            }
          })
          Object.keys(that.formInline.dept_info).forEach(key=>{
            that.formInline.dept_info[key] = ""
            that.$set(that.formInline.dept_info,key,"")
          })
        })
        .catch(e=>{
          that.index--
          this.$message({
            message:e.message,
            type: 'error'
          });
        })
    },
    // 删除科室
    remove() {
      that.index++
      removeOrganization({id:that.nodeCurr.id})
      .then(res=>{
        that.index--
        that.handleDeleteFlag = false
        that.treeValue = ""
        that.getList() 
      })
      .catch(e=>{
        that.index--
    
        this.$message({
          message:e.message,
          type: 'error'
        });
      })
    },
  },
  destroyed(){
    // that.loading.close();
  },
 
}
</script>

<style lang="scss" scoped>
  // .el-button{
  //   background-color:#02BF6B;
  // }
.yisheng>>>.el-input--mini .el-input__inner {
    height: 40px !important;
    width: 100% !important;
    display: inline-block !important;
}
  .organization-padd{
    padding: 0 20px;
    box-sizing: border-box;
  }

  .buttom{
    text-align: right;
    margin-top:20px;
    margin-bottom: 20px;
  }

  .pd-20{
    padding:0px 20px;
    box-sizing: border-box;
  }  
  >>> .el-tree-node__content {
    &:hover {
      // background: #89c2f7; 
      // background: red;
    }
    height:40px;
    display: flex !important;
    flex-wrap: wrap;
    justify-content:flex-start;
  }
  .node >>> .el-dropdown .el-input__inner{
    height:30px;
    
  }
  .node >>> .el-dropdown{
    width: 100px;
    line-height: 30px;
    height: 30px;
    // margin-left: 50px;
    margin-left: auto;
  }


  .custom-tree-title{
    display: inline-block;
    height: 30px;
  }
  
  >>> .el-input__icon {
    line-height: 30px;
  }
  .section-content{
    // height: calc(100vh - 90px);
    display: flex;
  }

  .node{
    width: 90%;
    display: flex;
    line-height: 30px;
  }

  .flexBetween{
    display: flex;
    justify-content: space-between;
  }

  .scrool{
    overflow-y: scroll;
    height:700px;
    display: block;
  }
 
  .flex /deep/ .el-dialog{
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

</style>
